<div class="full_w">
    <div class="h_title"><?php echo Yii::t('AdmincpModule.admincp', 'Add photo'); ?></div>
    <?php 
        foreach(Yii::app()->admin->getFlashes() as $key => $message){
            echo '<div class="n_'.$key.'"><p>'.$message."</p></div>\n";
        }
    ?>
    <form method="post" id="frmAdd">
        <div class="element">
            <label for="name">Images</label>
            <input type="text" name="photo[]" class="text" value="" autocomplete="off" onClick="obj = this; Media.show({callback: function(src){obj.value = src; $.fancybox.close();}, folder: 'post_<?php echo $intPostParentId; ?>'});"> 
        </div>   
        <div class="entry">
        	<button type="button" name="more" id="more" onClick="addMore();">More...</button>
            <input type="hidden" name="id" id="id" value="<?php echo isset($arrItemInfo['post_id'])?$arrItemInfo['post_id']:null; ?>">
            <button type="submit">Add</button> <button>Cancel</button>
        </div>
    </form>
    
    <div class="sep"></div>
    <form method="post" id="frmPhotos">
    <ul id="photo-list">
		<?php foreach($arrPosts as $R): ?>
        <li>
            <div class="preview"><img src="<?php echo UPLOADS_URL.'/'.$R['post_image']; ?>"></div>
            <div class="form">
                <label>Title:</label><input type="text" class="text" name="title[<?php echo $R['post_id']; ?>]" value="<?php echo $R['post_title']; ?>"><br>
                <label>Desc:</label><textarea class="textarea" name="intro[<?php echo $R['post_id']; ?>]"><?php echo $R['post_intro']; ?></textarea>
                <input type="hidden" name="img[<?php echo $R['post_id']; ?>]" value="<?php echo $R['post_image']; ?>">
                <a href="<?php echo LINK_ADMINCP_GALLERY.'/delete/?id='.$R['post_id']; ?>">Delete</a>
            </div>
        </li>
        <?php endforeach; ?>        
    </ul>
    
    <div class="entry">
        <input type="hidden" name="id" id="id" value="<?php echo $intPostParentId; ?>">
        <button type="submit">Save</button> <button>Cancel</button>
    </div>
    
</div>
<style type="text/css">
	#photo-list{
		float:left;
		width: 100%;
		list-style: none outside none;
	}
	#photo-list li{
		
		float:left;
		width: 180px;
		height:360px;
		margin:5px;
		padding:2px;
	}
	
	#photo-list li .preview{
		border: 1px solid #BDBDBD;
		float: left;
		text-align: center;
		vertical-align: middle;
		width:180px;
		height:180px;
	}
	
	#photo-list li .preview img{
		max-width: 180px;
		max-height: 180px;
	}
	
	#photo-list li .form{
		float: left;
	}
</style>
<div id="sample" style="display:none">
    <div class="element">
        <label for="name">Images</label>
        <input type="text" name="photo[]" class="text" value="" autocomplete="off" onClick="obj = this; Media.show({callback: function(src){obj.value = src; $.fancybox.close();}, folder: 'post_<?php echo $intPostParentId; ?>'});"> 
    </div>   
</div>
<script type="text/javascript" src="js/media-popup.js"></script>
<script type="text/javascript">
	function addMore(){
		$('#frmAdd .entry').before($('#sample').html());
	}
</script>
